package ca.scotthyndman.as2haxe.dom;

/**
 * Descriptor for a child list property of an AST node. A child list property is
 * one whose value is a list of {@link ASTNode}.
 */
public class ASChildListPropertyDescriptor extends ASPropertyDescriptor {

	/**
	 * Element type. For example, for a node type like ASCompilationUnit, the
	 * "imports" property is ASImportDeclaration.class.
	 * <p>
	 * Field is private, but marked package-visible for fast access from
	 * ASTNode.
	 * </p>
	 */
	final Class<? extends ASTNode> elementType;

	/**
	 * Creates a new child list property descriptor with the given property id.
	 * Note that this constructor is declared package-private so that property
	 * descriptors can only be created by the AST implementation.
	 * 
	 * @param nodeClass
	 *            concrete AST node type that owns this property
	 * @param propertyId
	 *            the property id
	 * @param elementType
	 *            the element type of this property
	 */
	ASChildListPropertyDescriptor(Class<? extends ASTNode> nodeClass,
			String propertyId, Class<? extends ASTNode> elementType) {
		super(nodeClass, propertyId);
		if (elementType == null) {
			throw new IllegalArgumentException();
		}
		this.elementType = elementType;
	}

	/**
	 * Returns the element type of this list property.
	 * <p>
	 * For example, for a node type like CompilationUnit, the "imports" property
	 * returns <code>ImportDeclaration.class</code>.
	 * </p>
	 * 
	 * @return the element type of the property
	 */
	public final Class getElementType() {
		return this.elementType;
	}
}
